//
//  ResponseError.swift
//  APPDomain
//
//  Created by raymond Peng on 2018/7/26.
//  Copyright © 2018 TanBaYe. All rights reserved.
//

import Foundation

/// 数据错误
public struct DataError: CommonError {
    /// 错误码
    public let errorCode: Int
    /// 错误信息
    public let errorMessage: String

    public init(errorCode: Int, errorMessage: String) {
        self.errorCode = errorCode
        self.errorMessage = errorMessage
    }

    /// 返回一个 "doorKeeper" 类型的错误
    public static func unknownError() -> DataError {
        return DataError(errorCode: -65534, errorMessage: "系统繁忙, 请稍后重试.")
    }

    public static func deserializationError() -> DataError {
        return DataError(errorCode: -65533, errorMessage: "解析数据失败")
    }
}
